
const myCopy = (app: any) => {
  app.directive('myCopy', {
    mounted(el: Element, {value}: any) {
      el.addEventListener('click', () => {
        if (!value) {
          alert('Empty')
          return
        }
        const textarea = document.createElement('textarea');
        textarea.readOnly = true
        textarea.style.position = 'absolute'
        textarea.style.left = '-99999px'
        textarea.value = value
        document.body.appendChild(textarea)
        textarea.select()
        textarea.setSelectionRange(0, textarea.value.length)
        const result = document.execCommand('Copy')
        if (result) {
          alert('copied!')
        }
        document.body.removeChild(textarea)
      })
    }
  })
}

export default myCopy
export { myCopy }




